package com.mc.algorithm;
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.Map;
public class FirstStr {
    public int FirstNotRepeatingChar(String str) {
        
        LinkedHashMap<Character,Integer> map = new LinkedHashMap<Character,Integer>();
        for(int i=0;i<str.length();i++){
            if(map.containsKey(str.charAt(i)))
                map.put(str.charAt(i),map.get(str.charAt(i))+1);
            else
                map.put(str.charAt(i),1);
        }
        Iterator<Map.Entry<Character,Integer>> iter = map.entrySet().iterator();
       	char ch=0;
        while(iter.hasNext()){
            
            Map.Entry<Character,Integer> en = iter.next();
            ch = en.getKey();
            if(en.getValue()==1)
                break;
        }
        
        return str.indexOf(ch);
    }
}